package org.skydiveapp;

import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.TextView;

public class BaseListActivity extends ListActivity
{
	private OnClickListener leftClickListener = new OnClickListener()
	{
		@Override
		public void onClick(View view)
		{
			onLeftImageButtonClick();
		}
	};
	private OnClickListener rightClickListener = new OnClickListener()
	{
		@Override
		public void onClick(View view)
		{
			onRightImageButtonClick();
		}
	};
	
    @Override 
    public void onCreate(Bundle savedInstanceState)
    { 
    	super.onCreate(savedInstanceState);
    	
    	// show view
		setContentView(R.layout.list_view);
		
		// add listeners
		ImageButton leftButton = (ImageButton)findViewById(R.id.ListHeaderLeftButton);
		leftButton.setOnClickListener(leftClickListener);
		
		ImageButton rightButton = (ImageButton)findViewById(R.id.ListHeaderRightButton);
		rightButton.setOnClickListener(rightClickListener);
    }
    
    protected void onLeftImageButtonClick()
    {
    	// do nothing
    }
    
    protected void onRightImageButtonClick()
    {
    	// do nothing
    }
    
    protected void setHeaderText(int id)
    {
		// set header label
		TextView textView = (TextView)findViewById(R.id.ListHeaderTextView);
		textView.setText(id);
    }
    
    protected void setLeftButtonImage(int id)
    {
    	ImageButton button = (ImageButton)findViewById(R.id.ListHeaderLeftButton);
    	button.setImageResource(id);
    }
    
    protected void setLeftButtonVisibility(int visibility)
    {
    	ImageButton button = (ImageButton)findViewById(R.id.ListHeaderLeftButton);
    	button.setVisibility(visibility);
    }
    
    protected void setRightButtonImage(int id)
    {
    	ImageButton button = (ImageButton)findViewById(R.id.ListHeaderRightButton);
    	button.setImageResource(id);
    }
    
    protected void setRightButtonVisibility(int visibility)
    {
    	ImageButton button = (ImageButton)findViewById(R.id.ListHeaderRightButton);
    	button.setVisibility(visibility);
    }
}
